package com.wobito.common.config;

import com.wobito.common.interceptor.AntiBrushInterceptor;
import com.wobito.common.interceptor.SignatureInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author Wangbaba
 * @Date 2024/9/9 15:32
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private SignatureInterceptor signatureInterceptor;
    @Autowired
    private AntiBrushInterceptor antiBrushInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //接口防刷
        registry.addInterceptor(antiBrushInterceptor)
                .addPathPatterns("/**");
        //外部接口鉴权 后台管理系统不需要因为有token
        registry.addInterceptor(signatureInterceptor)
                .addPathPatterns("/smartBookApi/**","/operate/**");
    }
}
